﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Products;

public partial class product_Brand : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Request.QueryString["Id"] != null)
            {
                Product.showbrandheader(Brand.GetBrandDetail(Convert.ToInt16(Request.QueryString["Id"].Split('-')[0])),litHeader);
                BindData();

            }
        }
    }
    public void BindData()
    {
        this.Lvitem.DataSource = Product.GetProductByBrand(int.Parse(Request.QueryString["id"].Split('-')[0]));
        this.Lvitem.DataBind();
    }
    protected void Lvitem_PagePropertiesChanging(object sender,System.Web.UI.WebControls.PagePropertiesChangingEventArgs e)
    {
        //DataPager myPager = (DataPager)this.Lvitem.FindControl("pager");
        //myPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
        //Literal PageInfo = (Literal)this.Lvitem.FindControl("PageInfo");
        //String Prefix = "";
        //int CurrentPage = (e.StartRowIndex / e.MaximumRows) + 1;
        //Double totalPage = Math.Ceiling(Convert.ToDouble(myPager.TotalRowCount) / Convert.ToDouble(myPager.PageSize));
        //PageInfo.Text = Prefix + CurrentPage + " / " + totalPage;
        DataPager myPager = (DataPager)this.Lvitem.FindControl("pager");
        myPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
        Literal PageInfo = (Literal)this.Lvitem.FindControl("PageInfo");
        String Prefix = String.Compare("vn", "vn", true) == 0 ? "Xem trang: " : "Views: ";
        int CurrentPage = (e.StartRowIndex / e.MaximumRows) + 1;
        Double totalPage = Math.Ceiling(Convert.ToDouble(myPager.TotalRowCount) / Convert.ToDouble(myPager.PageSize));
        PageInfo.Text = Prefix + CurrentPage + " / " + totalPage;
        BindData();
    }
    protected void pager_PreRender(object sender, EventArgs e)
    {
        BindData();
    }
}
